#ifndef POSTSCRIPT_STREAM_H
#define POSTSCRIPT_STREAM_H

#include <iostream>
#include <fstream>
#include <string>

class Postscript_Stream {
public:
    Postscript_Stream(const std::string& filename);
    virtual ~Postscript_Stream();
    void open(const std::string& filename);

    void set_bounds(double BLx, double BLy, double TRx, double TRy);
    void end_page();

    void draw_line(double x1, double y1, double x2, double y2);
    void join_dots(double x1, double y1, double x2, double y2);
    void draw_dot(double x, double y, bool solid);
    void draw_label(const std::string& label, double x, double y);
    void draw_caption(const std::string& label);
    void label_dot (const std::string& label, double x, double y);
    void set_font_size(int points);
    void set_dot_size(int points);
    void close();
    void flush();

private:
    void header();
    void trailer();
    void wcs_to_dcs(double xw, double yw, double& xd, double& yd);

private:
    std::ofstream ps_file;
    double font_size;
    double dot_size;
    double dot_size_wcs;
    double BLx,BLy, TRx,TRy;
    double wcs_to_dcs_scale;
    double page_width_inches;
    double page_height_inches;
    double points_per_inch;
    double margin;
    int page_number;
};

#endif


